/** \file rsrclist.h
 *
 * \brief Store basic local and extern rsrc informations.
 */

#ifndef RL_H
#define RL_H

#include <stdio.h>
#include "../global.h"
#include "../chainedlib/chainedlist.h"


/// The neighbour list
extern CLNode_s* RL_list;

/// Resource type
typedef struct _resource_s
{
  filekey_t  key;
  char       name[FILENAME_MAX];
  size_t     size;
  ip_port_s  host;
  char       local;
} resource_s;


/// Intialize the resource list
void RL_init(void);

/// Destroy the resource list
void RL_destroy(void);

/** \brief Add or update a resource
 * A local resource will replace an existing external resource.
 * Resource are compared with their keys.
 */
void RL_add(resource_s* rsrc);

/// Remove a resource (with the key of rsrc)
void RL_remove(resource_s* rsrc);

/** \brief Compare two resources, using file key
 * Used for searching in the list.
 * \return 1 if equal, 0 if not equal
 */
inline char RL_test(resource_s* rsrc1, resource_s* rsrc2);


#endif

